<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Article extends Model
{
    use HasFactory;

    protected $fillable = ['title', 'fields'];
    protected $casts = [
        'fields' => 'json'
    ];

    public function houses()
    {
        return $this->hasMany(House::class)->latest();
    }

    public function notices()
    {
        return $this->hasMany(Notice::class)->latest();
    }

    public function cars()
    {
        return $this->hasMany(Car::class)->latest();
    }

    public function pets()
    {
        return $this->hasMany(Pet::class)->latest();
    }

    public function useds()
    {
        return $this->hasMany(Used::class)->latest();
    }

    public function ads()
    {
        return $this->hasMany(Ad::class)->latest();
    }
}
